package top.stmo.springMVC.controller;

import org.springframework.web.bind.annotation.*;
import top.stmo.springMVC.pojo.User;

/**
 *       Rest 风格     简化版
 */

@RestController
@RequestMapping("/userss")
public class UserRestController3 {

    @PostMapping
    public String save1() {
        System.out.println("users save");
        return "users save";
    }

    @DeleteMapping("/{id}")
    public String delete(@PathVariable Integer id) {
        System.out.println("users delete");
        System.out.println(id);
        return "users delete";
    }

    @PutMapping
    public String update(@RequestBody User user) {
        System.out.println("users update");
        System.out.println("Users：" + user);
        return "users update";
    }

    @GetMapping("/{id}")
    public String getById(@PathVariable Integer id) {
        System.out.println("users getById");
        System.out.println("Users：" + id);
        return "users getById";
    }

    @GetMapping
    public String getAll() {
        System.out.println("user getAll");
        return "user getAll";
    }
}
